package view;

import cn.hutool.core.lang.Singleton;
import listener.FocusLostAutoHideListener;

import javax.swing.*;
import java.awt.*;

/**
 * @author zhangpeiwen
 * @since 2020/10/1
 */
public class HomePage extends JFrame {
    static{
        // 避免MacOS中出现dock icon
//        -Dapple.awt.UIElement=true
//        System.setProperty("ap ple.awt.UIElement", "true");
    }

    private HomePage (){

//        this.setUndecorated(true);


        this.setResizable(false);
        this.setFocusable(true);
        this.setAutoRequestFocus(true);
        this.setAlwaysOnTop(true);
        this.setLayout(new GridLayout(2, 5));

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        //height of the task bar
        Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
        int taskBarHeight = scnMax.bottom;

        System.out.println(taskBarHeight);

        this.setSize(screenSize.width, screenSize.height/3);
//        this.setOpacity(0.95f);
        this.setBackground(Color.WHITE);
        this.setLocation(0, screenSize.height - this.getHeight() - taskBarHeight);

//        this.add(new JButton("button"));


        // 失去焦点就隐藏窗体
        this.addWindowFocusListener(Singleton.get(FocusLostAutoHideListener.class));

        // 使窗体的任意部位都可以拖动
//        this.addMouseListener(Singleton.get(WindowDragListener.class));
//        this.addMouseMotionListener(Singleton.get(WindowDragListener.class));


        this.setVisible(true);
    }




}
